locals {
  dms_kafka_groups = {
    myapp = {
      cluster_name      = "dms-myapp-dev"
      ava_zone          = ["${var.REGION}a", "${var.REGION}b", "${var.REGION}b"]
      vpc_id            = data.terraform_remote_state.vpc.outputs.vpc_info.id
      subnet_id         = data.terraform_remote_state.subnet.outputs.subnet_info["subnet-me212-dev-baidu_hub-db-kafka"].id
      vsg_id            = data.terraform_remote_state.vsg.outputs.vsg_info.vsg_kafka.vsg_id
      flavor_id         = "c6.2u4g.cluster"
      engine_version    = "2.7"
      storage_spec_code = "dms.physical.storage.ultra.v2"
      storage_space     = 300
      retention_policy  = "time_base"
    }
  }
}

module "dms" {
  source                = "../../../modules/dms"
  for_each              = local.dms_kafka_groups
  cluster_name          = each.value.cluster_name
  vpc_id                = each.value.vpc_id
  subnet_id             = each.value.subnet_id
  vsg_id                = each.value.vsg_id
  flavor_id             = each.value.flavor_id
  storage_spec_code     = each.value.storage_spec_code
  availability_zones    = each.value.ava_zone
  storage_space         = each.value.storage_space
  retention_policy      = each.value.retention_policy
  engine_version        = each.value.engine_version
  manager_user          = var.manager_user_myapp
  manager_password      = var.manager_password_myapp
  enterprise_project_id = var.PROJECT_ID
}
